home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Games / WHDLoad / Src / slave-examples / interphase.asm < prev    next >
Encoding:
Assembly Source File  |  2000-01-23  |  5.2 KB  |  221 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    interphase.asm
  3. ;  :Contents.    Slave for "Interphase"
  4. ;  :Author.    wepl <wepl@whdload.org>
  5. ;  :Version.    $Id: interphase.asm 1.13 2000/01/23 21:02:51 jah Exp jah $
  6. ;  :History.    06.02.98 started
  7. ;        28.04.98 finished
  8. ;        02.05.98 flushcache inserted, now runs with cache enabled
  9. ;        15.06.98 savegame routine moved to external file
  10. ;        08.05.99 adapted for WHDLoad 10.0
  11. ;        23.01.00 adapted for changed whdmacros.i 10.5
  12. ;  :Requires.    -
  13. ;  :Copyright.    Public Domain
  14. ;  :Language.    68000 Assembler
  15. ;  :Translator.    Barfly 2.9, PhxAss 4.38
  16. ;  :To Do.
  17. ;---------------------------------------------------------------------------*
  18.  
  19.     INCDIR    Includes:
  20.     INCLUDE    whdload.i
  21.     INCLUDE    whdmacros.i
  22.  
  23.     IFD    BARFLY
  24.     OUTPUT    "wart:i/interphase/Interphase.Slave"
  25.     BOPT    O+                ;enable optimizing
  26.     BOPT    OG+                ;enable optimizing
  27.     BOPT    ODd-                ;disable mul optimizing
  28.     BOPT    ODe-                ;disable mul optimizing
  29.     BOPT    w4-                ;disable 64k warnings
  30.     SUPER                    ;disable supervisor warnings
  31.     ENDC
  32.  
  33. ;============================================================================
  34.  
  35. _base        SLAVE_HEADER            ;ws_Security + ws_ID
  36.         dc.w    10            ;ws_Version
  37.         dc.w    WHDLF_Disk|WHDLF_NoError|WHDLF_EmulTrap|WHDLF_NoDivZero    ;ws_flags
  38.         dc.l    $80000            ;ws_BaseMemSize
  39.         dc.l    0            ;ws_ExecInstall
  40.         dc.w    _Start-_base        ;ws_GameLoader
  41.         dc.w    0            ;ws_CurrentDir
  42.         dc.w    0            ;ws_DontCache
  43. _keydebug    dc.b    0            ;ws_keydebug
  44. _keyexit    dc.b    $59            ;ws_keyexit = F10
  45. _expmem        dc.l    0            ;ws_ExpMem
  46.         dc.w    _name-_base        ;ws_name
  47.         dc.w    _copy-_base        ;ws_copy
  48.         dc.w    _info-_base        ;ws_info
  49.  
  50. ;============================================================================
  51.  
  52.     IFD    BARFLY
  53.     IFND    .passchk
  54.     DOSCMD    "WDate  >T:date"
  55. .passchk
  56.     ENDC
  57.     ENDC
  58.  
  59. _name        dc.b    "Interphase",0
  60. _copy        dc.b    "1989,1990 Mirrorsoft Ltd.",0
  61. _info        dc.b    "installed & fixed by Wepl",10
  62.         dc.b    "version 1.13 "
  63.     IFD    BARFLY
  64.         INCBIN    "T:date"
  65.     ENDC
  66.         dc.b    0
  67.     EVEN
  68.  
  69. ;============================================================================
  70. _Start    ;    A0 = resident loader
  71. ;============================================================================
  72. ;
  73. ;    Image format:
  74. ;    Disk 1        tracks 2-75 = 373760
  75. ;
  76. ;============================================================================
  77.  
  78.         lea    (_resload,pc),a1
  79.         move.l    a0,(a1)                ;save for later using
  80.  
  81.         moveq    #0,d0                ;offset
  82.         move.l    #$1c+$48c0,d1            ;size
  83.         moveq    #1,d2                ;disk
  84.         lea    $400,a0                ;destination
  85.         move.l    (_resload,pc),a1
  86.         jsr    (resload_DiskLoad,a1)
  87.  
  88.         skip    6,$400+$98            ;dma on
  89.         ret    $400+$4532            ;vector init
  90.         patch    $400+$146,_1
  91.  
  92.         jmp    $400
  93.  
  94. _1        move.l    #$6400,d0            ;offset
  95.         move.l    #$1c+$545c6,d1            ;size
  96.         moveq    #1,d2                ;disk
  97.         move.l    $300,a0                ;destination
  98.         move.l    (_resload,pc),a1
  99.         jsr    (resload_DiskLoad,a1)
  100.  
  101.         move.w    #$4e40,$400+$212        ;trap #0
  102.         lea    (_2,pc),a0
  103.         move.l    a0,$80
  104.  
  105.         jmp    $400+$1ae
  106.  
  107. _2        move.w    #500,$400+$129c            ;time to wait
  108.         patch    $400+$30a0,_int6c
  109.         skip    $280-$26e,$400+$26e        ;drive stuff
  110.         patch    $400+$2f0,_3
  111.         jsr    $400+$114c            ;clr screen
  112.         bsr    _waitvb
  113.         move.w    #$87d0,(_custom+dmacon)
  114.         jsr    $400+$45e            ;original
  115.         addq.l    #2,(2,a7)
  116.         rte
  117.  
  118. _int6c        subq.w    #1,$400+$129c
  119.         btst    #6,$bfe001
  120.         beq    .q
  121.         btst    #7,$bfe001
  122.         beq    .q
  123.         btst    #2,(_custom+potinp)
  124.         bne    .n
  125. .q        move.w    #-1,$400+$129c
  126. .n        move.w    #$20,(_custom+intreq)
  127. _rte        rte
  128.  
  129. _3        bsr    _waitvb
  130.         move.w    #$7fff,(_custom+intena)
  131.         move.w    #$7fff,(_custom+dmacon)
  132.         move.w    #$7fff,(_custom+intreq)
  133.     ;    sub.w    #10,$a08            ;ignore unwanted ports interrupts
  134.         pea    (_keyint,pc)
  135.         move.l    (a7)+,$602
  136.         skip    $5a56-$548a,$548a        ;rn copylock
  137.         patch    $25f4,_savegame
  138.         patch    $2608,_loadgame
  139.  
  140.         move.l    (_resload,pc),a0
  141.         jsr    (resload_FlushCache,a0)        ;to fix af if icache enabled
  142.  
  143.         lea    $400,a0
  144.         jmp    (a0)
  145.  
  146. ;--------------------------------
  147.  
  148. _keyint        movem.l    d0-d1/a1,-(a7)
  149.         lea    (_ciaa),a1
  150.         btst    #CIAICRB_SP,(ciaicr,a1)        ;check int reason
  151.         beq    .int2_exit
  152.         move.b    (ciasdr,a1),d0            ;read code
  153.         clr.b    (ciasdr,a1)            ;output LOW (handshake)
  154.         or.b    #CIACRAF_SPMODE,(ciacra,a1)    ;to output
  155.         not.b    d0
  156.         ror.b    #1,d0
  157.  
  158.         move.b    d0,$591
  159.         jsr    $a52
  160.  
  161.         cmp.b    (_keyexit,pc),d0
  162.         beq    _exit
  163.  
  164.         cmp.b    #$5f,d0
  165.         bne    .1
  166.         eor.w    #$f16c,$775a            ;trainer (John Selck)
  167.         move.w    #$210,$4ec
  168. .1
  169.         moveq    #2-1,d1                ;wait because handshake min 75 µs
  170. .int2_w1    move.b    (_custom+vhposr),d0
  171. .int2_w2    cmp.b    (_custom+vhposr),d0        ;one line is 63.5 µs
  172.         beq    .int2_w2
  173.         dbf    d1,.int2_w1            ;(min=127µs max=190.5µs)
  174.  
  175.         and.b    #~(CIACRAF_SPMODE),(ciacra,a1)    ;to input
  176. .int2_exit    move.w    #INTF_PORTS,(intreq+_custom)
  177.         movem.l    (a7)+,d0-d1/a1
  178.         rte
  179.  
  180. ;--------------------------------
  181.  
  182. _loadgame    move.l    #100,d0
  183.         lea    $65000,a1            ;free mem for screen
  184.         bsr    _sg_load
  185.         move.w    #$4100,(_custom+bplcon0)
  186.         move.w    #320/8*3,(_custom+bpl1mod)
  187.     ;    move.l    #$00000eee,(color,a6)
  188.         moveq    #0,d2
  189.         rts
  190.  
  191. _savegame    move.l    #100,d0
  192.         lea    $65000,a1            ;free mem for screen
  193.         bsr    _sg_save
  194.         move.w    #$4100,(_custom+bplcon0)
  195.         move.w    #320/8*3,(_custom+bpl1mod)
  196.     ;    move.l    #$00000eee,(color,a6)
  197.         moveq    #0,d2
  198.         rts
  199.  
  200. ;--------------------------------
  201.  
  202. _waitvb        waitvb
  203.         rts
  204.  
  205. _exit        pea    TDREASON_OK
  206.         move.l    (_resload,pc),-(a7)
  207.         add.l    #resload_Abort,(a7)
  208.         rts
  209.  
  210. ;--------------------------------
  211.  
  212. _resload    dc.l    0                ;address of resident loader
  213.  
  214. ;============================================================================
  215.  
  216.     INCLUDE    Sources:whdload/savegame.s
  217.  
  218. ;============================================================================
  219.  
  220.     END
  221.